package com.ruoyi.system.service.req;

import com.ruoyi.common.core.domain.entity.RestaurantStoreResource;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @Author: ruohao
 * @Date: 2023/8/26
 **/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CreateResourceDTO {
    @NotBlank(message = "食材名称不能为空")
    private String name;

//    @NotBlank(message = "食材图片不能为空")
    private String imageUrl;

    private String unit;

    private String type;

    private BigDecimal avgPrice;

    private Date guarantee;

    private BigDecimal up;

    private BigDecimal down;

    public static RestaurantStoreResource convertToDO(CreateResourceDTO createResourceDTO) {
        if (createResourceDTO == null) {
            return null;
        }
        return RestaurantStoreResource.builder()
                .name(createResourceDTO.getName())
                .imageUrl(createResourceDTO.getImageUrl())
                .up(createResourceDTO.getUp())
                .down(createResourceDTO.getDown())
                .guarantee(createResourceDTO.getGuarantee())
                .avgPrice(createResourceDTO.getAvgPrice())
                .unit(createResourceDTO.getUnit())
                .type(createResourceDTO.getType())
                .build();
    }
}
